<?php /* Smarty version 2.6.11, created on 2011-06-22 12:12:58
         compiled from system_make.php */ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>生成</title>
<LINK href="style/css/ui-lightness/jquery-ui-1.8.8.custom.css" type=text/css rel=stylesheet>
<SCRIPT src="style/js/jquery-1.4.2.min.js" type=text/javascript></SCRIPT>
<SCRIPT src="style/js/jquery-ui-1.8.6.custom.min.js" type=text/javascript></SCRIPT>
</head>

<body>
<style>
.ui-progressbar-value { background-image: url(/style/css/ui-lightness/images/pbar-ani.gif); background-repeat:repeat }
.sp {float:right; padding-right:20px; color:green;}
</style>
<script>
json	= <?php echo $this->_tpl_vars['json']; ?>
;
maked	= 0;
var date	= new Date;
startT	= date.getTime();
$(function() {
	$( "#progressbar" ).progressbar({value: 0});
	$("#end").html(json.num);
	toMake({key:0});
});

function toMake(r)
{
	if (json.action[r.key] !== undefined)
	{
		r.start = r.start ? r.start : 0;
		if (json.action[r.key] == 'index') var par = {'action':json.action[r.key],'wid':json.wid};
		if (json.action[r.key] == 'column') var par = {'action':json.action[r.key],'wid':json.wid,'classid':json.classid,'start':r.start};
		if (json.action[r.key] == 'page') var par = {'action':json.action[r.key],'wid':json.wid,'classid':json.classid,'start':r.start,'id':json.id};
		$.getJSON('index.php?m=system&a=toMake',par,function(data){
			showMessage(data);
			if (data.start>=json.row[r.key])
			{
				r.key+=1;
				r.start=0;
			}
			else r.start = data.start;
			toMake(r);
		});
	}
	
}
function showMessage(data)
{
	if (typeof(data.done)==undefined) alert(data.done);
	maked += data.done;
	$("#start").html(maked);
	
	$( "#progressbar" ).progressbar({value: maked/json.num*100});
	$(data.url).each(function(key,value){
		var s	= '';
		if (key%2 == 0) s='background:#F3F8F7;'; 
		$(".list").append('<div style="height:20px;'+s+'"><a href="'+data.url[key]+'" target="_blank" style="float:left;">'+data.title[key]+'</a><span class="sp"> &raquo; 生成完成</span></div>');
	});
	
	var date	= new Date;
	var endT	= date.getTime();
	var	t		= (endT-startT)/1000;
	$("#time").html(t.toFixed(2));
	
	$("#pj").html((t/maked).toFixed(2));
	
	if (maked >= json.num) document.getElementById("close").style.display = '';
}
</script>
<div class="demo" align="center" style="width:60%;">
	<div id="progressbar" style="height:12px;"></div>
    <div class="demo-description">
        <p>
        <code>
        进度：<code id="start">0</code>/<code id="end">0</code>
        耗时：<code id="time">0</code>秒
        平均: <code id="pj">0</code>
        <code id="close" style="display:none; color:green;">所有页面生成完成 <a href="javascript:window.close();">关闭页面</a></code>
        </code>
        </p>
	</div><!-- End demo-description -->
    <code><div class="list" align="left"></div></code>
</div><!-- End demo -->


</body>
</html>